package com.jp.lock;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class ReadWriteLockTest {
    final private static ReadWriteLock rwLock = new ReentrantReadWriteLock();


    public static void main(String[] args) {

        Lock readLock = rwLock.readLock();
        Lock writeLock = rwLock.writeLock();

        readLock.lock();
        System.out.println("get read lock");
        writeLock.lock();
        System.out.println("get write lock");
        try {

        }catch (Exception e){

        }finally {
            readLock.unlock();
        }
    }
}
